package com.jp.knowledge.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;

import com.jp.knowledge.R;
import com.jp.knowledge.model.HeadLineData;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;

/**
 * Created by 528787067@qq.com on 2017/7/18.
 */

public class JobKnowledgeDetailAdapter extends CommtemAdapter {

	public JobKnowledgeDetailAdapter(Context context, List infos) {
		super(context, infos);
	}

	@Override
	public int getLayoutId() {
		return R.layout.item_job_knowledge_detail;
	}

	@Override
	protected void renderData(JPRecycleViewHolder holder, Object item, int position) {
		super.renderData(holder, item, position);
		holder.getView(R.id.type).setVisibility(View.GONE);
		holder.getView(R.id.navType).setVisibility(View.GONE);
		holder.getView(R.id.icon_close).setVisibility(View.GONE);

		View itemMainView = holder.getView(R.id.main_view);
		itemMainView.setTag(position);
		itemMainView.setOnClickListener(this);
		View cancelBtn = holder.getView(R.id.cancel_btn);
		cancelBtn.setTag(position);
		cancelBtn.setOnClickListener(this);
	}

	@Override
	public void onClick(View view) {
		if(view.getId() == R.id.main_view){
			if(itemClickEventListener != null)
				itemClickEventListener.onItemClick((int) view.getTag());
		} else if(view.getId() == R.id.cancel_btn){
			if(itemClickEventListener != null)
				itemClickEventListener.onCancelClick((int) view.getTag());
		} else {
			super.onClick(view);
		}
	}

	private ItemClickEventListener itemClickEventListener;

	public void setItemClickEventListener(ItemClickEventListener itemClickEventListener){
		this.itemClickEventListener = itemClickEventListener;
	}

	public interface ItemClickEventListener{
		void onItemClick(int position);
		void onCancelClick(int position);
	}
}
